﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using CCWP7.Bare.ViewModels;
using Microsoft.Phone.Shell;

namespace CCWP7.Bare
{
    public partial class AddServerPage : PhoneApplicationPage
    {
        public AddServerPage()
        {
            InitializeComponent();

            ViewModel.PropertyChanged += ViewModel_PropertyChanged;
        }

        void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == AddServerViewModel.STR_AddServerEnabled)
                ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = ViewModel.AddServerEnabled;
        }

        AddServerViewModel ViewModel { get { return (AddServerViewModel)DataContext; } }

        void AddServer_Click(object sender, EventArgs e)
        {
            ViewModel.AddServer();
        }

        private void Cancel_Click(object sender, EventArgs e)
        {
            ViewModel.Cancel();
        }

        private void ServerUri_BindingValidationError(object sender, ValidationErrorEventArgs e)
        {

        } 
    }
}